package com.salefinder.client;

import com.extjs.gxt.ui.client.Style.HorizontalAlignment;
import com.extjs.gxt.ui.client.widget.LayoutContainer;
import com.extjs.gxt.ui.client.widget.button.Button;
import com.extjs.gxt.ui.client.widget.form.DateField;
import com.extjs.gxt.ui.client.widget.form.FormButtonBinding;
import com.extjs.gxt.ui.client.widget.form.FormPanel;
import com.extjs.gxt.ui.client.widget.form.SimpleComboBox;
import com.extjs.gxt.ui.client.widget.form.TextArea;
import com.extjs.gxt.ui.client.widget.form.TextField;
import com.extjs.gxt.ui.client.widget.layout.FitLayout;
import com.extjs.gxt.ui.client.widget.layout.FormData;
import com.extjs.gxt.ui.client.widget.layout.TableLayout;
import com.google.gwt.user.client.Element;

public class AddItemScreen extends LayoutContainer{

	@Override
	protected void onRender(Element parent, int index) { 
		super.onRender(parent, index);
		this.setLayout(new FitLayout());
		LayoutContainer hp = new LayoutContainer();
		TableLayout layout = new TableLayout();
		hp.setLayout(layout);
		
//		hp.setSpacing(10);
		FormPanel searchPanel = new FormPanel();
		searchPanel.setHeading("Add a Sale Product");
		
		FormData formData = new FormData("-20");
		   
		SimpleComboBox<String> category = new SimpleComboBox<String>();
		category.add("Toronto");
		category.setFieldLabel("Category");
		searchPanel.add(category, formData);
		
		SimpleComboBox<String> name = new SimpleComboBox<String>();
		name.add(Suggestion.productNameSuggestions);
		name.setFieldLabel("Product");
		searchPanel.add(name, formData);
		
		SimpleComboBox<String> brand = new SimpleComboBox<String>();
		brand.add(Suggestion.productNameSuggestions);
		brand.setFieldLabel("Product");
		searchPanel.add(brand, formData);		
		
		TextField<Integer> quantity = new TextField<Integer>();  
		quantity.setFieldLabel("Size/Quantity");  
		quantity.getFocusSupport().setPreviousId(searchPanel.getButtonBar().getId());  
	    searchPanel.add(quantity, formData); 
	    
		TextField<String> unit = new TextField<String>();  
		unit.setFieldLabel("Unit of measure");    
		unit.getFocusSupport().setPreviousId(searchPanel.getButtonBar().getId());  
	    searchPanel.add(unit, formData); 
	    
		SimpleComboBox<String> merchant = new SimpleComboBox<String>();
		merchant.add(Suggestion.productNameSuggestions);
		merchant.setFieldLabel("Merchant");
		searchPanel.add(merchant, formData);	
		
		TextField<Double> basePrice = new TextField<Double>();  
		basePrice.setFieldLabel("Base Price");    
		basePrice.getFocusSupport().setPreviousId(searchPanel.getButtonBar().getId());  
	    searchPanel.add(basePrice, formData); 
	    
		TextField<Double> salePrice = new TextField<Double>();  
		salePrice.setFieldLabel("Unit of measure");    
		salePrice.getFocusSupport().setPreviousId(searchPanel.getButtonBar().getId());  
	    searchPanel.add(salePrice, formData); 

		DateField dateExpired = new DateField();  
		dateExpired.setFieldLabel("Unit of measure");   
		dateExpired.getFocusSupport().setPreviousId(searchPanel.getButtonBar().getId());  
	    searchPanel.add(dateExpired, formData); 
		
		SimpleComboBox<String> location = new SimpleComboBox<String>();
		location.add(Suggestion.productNameSuggestions);
		location.setFieldLabel("Purchase location");
		searchPanel.add(location, formData);	
		
		TextArea note = new TextArea();
		note.setFieldLabel("Notes");
		searchPanel.add(note);
		
	    Button b = new Button("Search");  
	    searchPanel.addButton(b);
	    searchPanel.setButtonAlign(HorizontalAlignment.CENTER); 

	    FormButtonBinding binding = new FormButtonBinding(searchPanel);  
	    binding.addButton(b);  
		
	    hp.add(searchPanel);
	    this.add(hp);
		
		
	}
}
